package com.dxy.controller;

import com.dxy.bean.MenoBean;
import com.dxy.serviceImpI.MenoServiceImpI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/meno")
public class MenoController {
    //将Service 注入Web层
    @Autowired
    private MenoServiceImpI menoServiceImpI;
    @RequestMapping(value = "/selectAll")
    @ResponseBody
    public List<MenoBean> listMeno() {
        return menoServiceImpI.getMessages();
    }

    @RequestMapping(value = "/selectStatus0")
    @ResponseBody
    public List<MenoBean> listMenoBystatus0() {
        return menoServiceImpI.getMessagesBystatus0();
    }

    @RequestMapping(value = "/selectStatus1")
    @ResponseBody
    public List<MenoBean> listMenoBystatus1() {
        return menoServiceImpI.getMessagesBystatus1();
    }

    @RequestMapping(value = "/selectStatus2")
    @ResponseBody
    public List<MenoBean> listMenoBystatus2() {
        return menoServiceImpI.getMessagesBystatus2();
    }

    @RequestMapping(value = "/insert", method = RequestMethod.GET)
    @ResponseBody
    public int insert(MenoBean menoBean) {
        return menoServiceImpI.saveMessages(menoBean);
    }

    @RequestMapping(value = "/update", method = RequestMethod.GET)
    @ResponseBody
    public int update(MenoBean menoBean) {
        return menoServiceImpI.updateMessages(menoBean);
    }

    @RequestMapping(value = "/getMeno", method = RequestMethod.GET)
    @ResponseBody
    public MenoBean getMeno(int meno_id) {
        return menoServiceImpI.getMessagesById(meno_id);
    }

    @RequestMapping(value = "/delete", method = RequestMethod.GET)
    @ResponseBody
    public int deletemeno(int meno_id) {
        return menoServiceImpI.delete(meno_id);
    }


}
